const fs = require("fs");

const path = require("path");

const sourcePath = path.join("arena-zh-rename");
fs.existsSync(sourcePath);
if (!sourcePath) {
  fs.mkdirSync(sourcePath, { recursive: true });
}

fs.readdirSync(sourcePath).forEach(async (file) => {
  const ucIdx = file.indexOf("UC");
  let newFile = file
    .substring(ucIdx === -1 ? 0 : ucIdx)
    .replace("_", "_p")
    .replace("-", "_");

  fs.renameSync(path.join(sourcePath, file), path.join(sourcePath, newFile));
});

// TODO CONAN

// fs.readdirSync(path.join('cardlist')).forEach(async file => {
// 	const image = path.join('cardlist', file);
// 	// console.log(file);
// 	const output = path.join('thumbnails', file);
// 	await sharp(image)
// 		.resize(200)
// 		.jpeg({ quality: 80 })
// 		.toBuffer().then(data => {
// 			fs.writeFileSync(output, data);
// 			console.log(output + ' : done');
// 		}).catch(err => console.log(err));
// });

// TODO TIERS
// const image = path.join('tier-full.png');
// const output = path.join('tier-full.jpg');
// sharp(image)
// 	.jpeg({ quality: 80 })
// 	.toBuffer().then(data => {
// 		fs.writeFileSync(output, data);
// 		console.log(output + ' : done');
// 	}).catch(err => console.log(err));
